package IC.Types;

/**
 * Created by IntelliJ IDEA.
 * User: nimrod
 * Date: 09/01/12
 * Time: 14:03
 * To change this template use File | Settings | File Templates.
 */
public abstract class Type {
    private static int currentId = 1;

    private String name;
    private int id;
    
    protected Type(String name) {
        this.name = name;
        this.id = currentId;
        currentId++;
    }

    public String getName() {
        return name;
    }

    public int getId() {
        return id;
    }

    public abstract boolean subtypeOf(Type t);
    public abstract boolean isReferenceType();


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Type type = (Type) o;

        if (name != null ? !name.equals(type.name) : type.name != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
